Skip to content

Conversation

@roscamaxim
Copy link
Contributor

@roscamaxim roscamaxim commented Apr 8, 2025

Problem

The http_date() function in xcover/utils.py incorrectly used mktime() to convert UTC time to a timestamp. Since mktime() interprets time tuples as local time, this caused the date header to be off by the local timezone offset (e.g., UTC+10 for Sydney). This resulted in authentication failures when clients were in different timezones.

In addition, the datetime.utcnow() is now deprecated and will be removed in a future version.

Solution

  • Replacing datetime.utcnow() with the timezone-aware datetime.now(timezone.utc)
  • Using direct string formatting with strftime() instead of mktime() and format_date_time()
  • Ensuring the date header is properly formatted according to RFC 7231

Changes

  • Fixed: http_date() function in xcover/utils.py to correctly handle UTC time
  • Added: Unit test in tests/test_utils.py to verify the function works correctly
  • Improved: README formatting by converting configuration options to a table
  • Fixed: Typo in README (changed "poertry" to "poetry")
  • CI fixed: updated GitHub Actions to the latest versions and resolved CI artifacts conflicts.

Testing

  • Uses mocking to ensure deterministic testing
  • Verifies the function calls datetime.now() with timezone.utc
  • Confirms the output format is correct

@codecov
Copy link

codecov bot commented Apr 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.43%. Comparing base (0d40c5e) to head (9e05ba2).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master       #5      +/-   ##
==========================================
- Coverage   95.47%   95.43%   -0.05%     
==========================================
  Files           7        7              
  Lines         221      219       -2     
==========================================
- Hits          211      209       -2     
  Misses         10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@roscamaxim
Copy link
Contributor Author

@tyomo4ka had to push some substantial updates to ci.yaml and semgrep.yml to get all GH checks passing—please give those a quick look, too.

@tyomo4ka tyomo4ka merged commit bbbd8e9 into CoverGenius:master Apr 10, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants